#pragma once

#include <QException>
#include <QString>

namespace cloud
{

class Exception : public QException
{
public:
    Exception(const QString& _s) : s(_s)
    {}
    void raise() const
    {
        printf("%s%s%s%s%s\n",
               "\033[0;31m",
               "terminate called after throwing an instance of 'cloud::Exception'\n",
               " what():  ",
               s.toUtf8().constData(),
               "\033[0m");
        fflush(stdout);
        QT_THROW(*this);
    }
private:
    QString s;
};

#ifndef THROW
#define THROW(s) \
    do { \
        cloud::Exception(s).raise(); \
    } while(0)
#endif

}
